//
//  CardBriefView.m
//  Guazi
//
//  Created by koolearn on 11-6-2.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "CardBriefView.h"

#define kLeft 5
#define kTop 5

@implementation CardBriefView

@synthesize card;


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}



- (void) drawRect:(CGRect)rect
{
    self.backgroundColor = [UIColor darkGrayColor];
    
    //name
    CGFloat y = kTop;
    [card.name drawInRect:CGRectMake( kLeft, y, 270, 20) withFont:[UIFont boldSystemFontOfSize:22]];
    
    //company
    y += 30;
    CGSize size = [card.company sizeWithFont:[UIFont systemFontOfSize:16]];
    [card.company drawInRect:CGRectMake(kLeft, y, kLeft + size.width, 18) withFont:[UIFont systemFontOfSize:16]];
    
    //position
    [card.position drawInRect:CGRectMake(kLeft + size.width + 5, y, 320 - kLeft - size.width - 5, 18) withFont:[UIFont systemFontOfSize:16]];
    
    UIColor *timestampColor = [UIColor darkGrayColor];
    [timestampColor set];

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetShadowWithColor(context, CGSizeMake(0, -1), 1, [[UIColor whiteColor] CGColor]);
   
    //phone
    y += 25;
    UIFont* font = [UIFont systemFontOfSize:13];
    [@"Mobile: " drawInRect:CGRectMake(kLeft, y, 43, 18) withFont:font lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentRight];
    [card.mobile drawInRect:CGRectMake(kLeft + 43, y, 160 - kLeft - 40, 18) withFont:font];
    
    //email
    y += 18;
    [@"E-Mail: " drawInRect:CGRectMake(kLeft, y, 43, 18) withFont:font lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentRight];
    [card.email drawInRect:CGRectMake(kLeft + 43, y, 120, 18) withFont:font];
}


- (void)dealloc
{
    [super dealloc];
}

@end
